#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define NUM_THREADS 2
void *BusyWork1(void *t) {
    int *x=t;
    printf("%d\n", *x);
}
void *BusyWork2(void *t) {
    char* x=t;
    printf("%c\n", *x);
}
int main(int argc, char *argv[]) {
    pthread_t thread[NUM_THREADS];
    pthread_attr_t attr;
int rc;
long t;
void *status;
/* Initialize and set thread detached attribute */
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
int zhengxing=233;
char zifu='A';
for (t = 0; t < NUM_THREADS; t++) {
    printf("Main: creating thread %ld\n", t);
    if(t==0)
        rc = pthread_create(&thread[t], &attr, BusyWork1, &zhengxing);
    if(t==1)
        rc = pthread_create(&thread[t], &attr, BusyWork2, &zifu);
    if (rc) {
        printf("ERROR; return code from pthread_create() is % d\n", rc);
    exit(-1);
    }
}
/* Free attribute and wait for the other threads */
pthread_attr_destroy(&attr);
for (t = 0; t < NUM_THREADS; t++) {
    rc = pthread_join(thread[t], &status);
    if (rc) {
    printf("ERROR; return code from pthread_join() is % d\n", rc);
    exit(-1);
    }
    printf("Main: completed join with thread %ld having a status of %ld\n",t, (long) status);
}
printf("Main: program completed. Exiting.\n");
pthread_exit(NULL);
}
